﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Utility.Network;
using System.Threading;
using System.Net;

namespace Utility
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            cl = new Client();
            sv = new Server();
            buf1 = new byte[1024];
            buf2 = new byte[1024];

            Thread thread1 = new Thread(StartServer);
            thread1.Start();
        }
        public void StartServer()
        {
            sv.StartListen(4444);
        }
        public void StartClient()
        {
            byte[] a = new byte[9000000];
            MessagePacket msg = new MessagePacket(1, "", a);
            buf1 = Serializer.Serialize(msg).ToArray();

            cl.SendAndReceive(Dns.GetHostAddresses("59.78.58.76")[0],4444, msg);
            box.Text = box.Text+"\nreceive ok";
        }
        Client cl;
        Server sv;
        private byte[] buf1;
        private byte[] buf2;

        private void button1_Click(object sender, EventArgs e)
        {
            StartClient();
        }
        
    }
}
